
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
# 基类层
class Base():
    # 初始化
    def __init__(self, driver):
        self.driver = driver
    # 获取浏览器
    def open_url(self,url):
        self.driver.find_element(url)
    # 显示等待
    def find_element(self,loc):
       WebDriverWait(self.driver,20,0.5).until(lambda driver: driver.find_element(self.driver.is_displayed))
       return self.driver.find_element(loc)
    # 输入
    def send_keys(self, loc, info):
        self.driver.find_element(loc).send_key(info)
    # 点击
    def click(self, loc):
        self.driver.click(loc)
    #(断言方法)提取文字
    def log_text(self,loc):
        return self.driver.find_element(*loc).text()
    # 切窗口
    def window(self):
        self.driver.switch_to.window(self.driver.window_handles[-1])
    # iframe框处理
    def ifrname(self,loc):
        self.driver.switch_to.frame(self.driver.find_element(loc))
    #  弹框处理
    def tanchuang(self,loc):
        self.driver.click(loc)
        self.driver.Select.select_by_index('-1')
    # 下拉滚动条
    def updown(self):
        self.driver.execute_script(0, 'scrollTo(qucement.body.scrollHeight())')


